/**
 * Copyright (c) 2000-2012 Liferay, Inc. All rights reserved.
 *
 * This library is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Lesser General Public License as published by the Free
 * Software Foundation; either version 2.1 of the License, or (at your option)
 * any later version.
 *
 * This library is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
 * details.
 */

package vn.com.fis.portal.model.impl;

import com.liferay.portal.kernel.bean.AutoEscapeBeanHandler;
import com.liferay.portal.kernel.exception.SystemException;
import com.liferay.portal.kernel.json.JSON;
import com.liferay.portal.kernel.util.GetterUtil;
import com.liferay.portal.kernel.util.ProxyUtil;
import com.liferay.portal.kernel.util.StringBundler;
import com.liferay.portal.kernel.util.StringPool;
import com.liferay.portal.model.CacheModel;
import com.liferay.portal.model.impl.BaseModelImpl;
import com.liferay.portal.service.ServiceContext;
import com.liferay.portal.util.PortalUtil;

import com.liferay.portlet.expando.model.ExpandoBridge;
import com.liferay.portlet.expando.util.ExpandoBridgeFactoryUtil;

import vn.com.fis.portal.model.FolderEntry;
import vn.com.fis.portal.model.FolderEntryModel;
import vn.com.fis.portal.model.FolderEntrySoap;

import java.io.Serializable;

import java.sql.Types;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

/**
 * The base model implementation for the FolderEntry service. Represents a row in the &quot;TBL_FOLDER&quot; database table, with each column mapped to a property of this class.
 *
 * <p>
 * This implementation and its corresponding interface {@link vn.com.fis.portal.model.FolderEntryModel} exist only as a container for the default property accessors generated by ServiceBuilder. Helper methods and all application logic should be put in {@link FolderEntryImpl}.
 * </p>
 *
 * @author loind
 * @see FolderEntryImpl
 * @see vn.com.fis.portal.model.FolderEntry
 * @see vn.com.fis.portal.model.FolderEntryModel
 * @generated
 */
@JSON(strict = true)
public class FolderEntryModelImpl extends BaseModelImpl<FolderEntry>
	implements FolderEntryModel {
	/*
	 * NOTE FOR DEVELOPERS:
	 *
	 * Never modify or reference this class directly. All methods that expect a folder entry model instance should use the {@link vn.com.fis.portal.model.FolderEntry} interface instead.
	 */
	public static final String TABLE_NAME = "TBL_FOLDER";
	public static final Object[][] TABLE_COLUMNS = {
			{ "folderId", Types.BIGINT },
			{ "folderName", Types.VARCHAR },
			{ "description", Types.VARCHAR },
			{ "createDate", Types.TIMESTAMP },
			{ "modifiedDate", Types.TIMESTAMP },
			{ "folderIdParent", Types.BIGINT },
			{ "userId", Types.BIGINT }
		};
	public static final String TABLE_SQL_CREATE = "create table TBL_FOLDER (folderId LONG not null primary key,folderName VARCHAR(75) null,description VARCHAR(75) null,createDate DATE null,modifiedDate DATE null,folderIdParent LONG,userId LONG)";
	public static final String TABLE_SQL_DROP = "drop table TBL_FOLDER";
	public static final String ORDER_BY_JPQL = " ORDER BY folderEntry.folderName ASC";
	public static final String ORDER_BY_SQL = " ORDER BY TBL_FOLDER.folderName ASC";
	public static final String DATA_SOURCE = "liferayDataSource";
	public static final String SESSION_FACTORY = "liferaySessionFactory";
	public static final String TX_MANAGER = "liferayTransactionManager";
	public static final boolean ENTITY_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.util.service.ServiceProps.get(
				"value.object.entity.cache.enabled.vn.com.fis.portal.model.FolderEntry"),
			true);
	public static final boolean FINDER_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.util.service.ServiceProps.get(
				"value.object.finder.cache.enabled.vn.com.fis.portal.model.FolderEntry"),
			true);
	public static final boolean COLUMN_BITMASK_ENABLED = GetterUtil.getBoolean(com.liferay.util.service.ServiceProps.get(
				"value.object.column.bitmask.enabled.vn.com.fis.portal.model.FolderEntry"),
			true);
	public static long FOLDERIDPARENT_COLUMN_BITMASK = 1L;
	public static long FOLDERNAME_COLUMN_BITMASK = 2L;
	public static long USERID_COLUMN_BITMASK = 4L;

	/**
	 * Converts the soap model instance into a normal model instance.
	 *
	 * @param soapModel the soap model instance to convert
	 * @return the normal model instance
	 */
	public static FolderEntry toModel(FolderEntrySoap soapModel) {
		FolderEntry model = new FolderEntryImpl();

		model.setFolderId(soapModel.getFolderId());
		model.setFolderName(soapModel.getFolderName());
		model.setDescription(soapModel.getDescription());
		model.setCreateDate(soapModel.getCreateDate());
		model.setModifiedDate(soapModel.getModifiedDate());
		model.setFolderIdParent(soapModel.getFolderIdParent());
		model.setUserId(soapModel.getUserId());

		return model;
	}

	/**
	 * Converts the soap model instances into normal model instances.
	 *
	 * @param soapModels the soap model instances to convert
	 * @return the normal model instances
	 */
	public static List<FolderEntry> toModels(FolderEntrySoap[] soapModels) {
		List<FolderEntry> models = new ArrayList<FolderEntry>(soapModels.length);

		for (FolderEntrySoap soapModel : soapModels) {
			models.add(toModel(soapModel));
		}

		return models;
	}

	public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.util.service.ServiceProps.get(
				"lock.expiration.time.vn.com.fis.portal.model.FolderEntry"));

	public FolderEntryModelImpl() {
	}

	public long getPrimaryKey() {
		return _folderId;
	}

	public void setPrimaryKey(long primaryKey) {
		setFolderId(primaryKey);
	}

	public Serializable getPrimaryKeyObj() {
		return new Long(_folderId);
	}

	public void setPrimaryKeyObj(Serializable primaryKeyObj) {
		setPrimaryKey(((Long)primaryKeyObj).longValue());
	}

	public Class<?> getModelClass() {
		return FolderEntry.class;
	}

	public String getModelClassName() {
		return FolderEntry.class.getName();
	}

	@JSON
	public long getFolderId() {
		return _folderId;
	}

	public void setFolderId(long folderId) {
		_folderId = folderId;
	}

	@JSON
	public String getFolderName() {
		if (_folderName == null) {
			return StringPool.BLANK;
		}
		else {
			return _folderName;
		}
	}

	public void setFolderName(String folderName) {
		_columnBitmask = -1L;

		if (_originalFolderName == null) {
			_originalFolderName = _folderName;
		}

		_folderName = folderName;
	}

	public String getOriginalFolderName() {
		return GetterUtil.getString(_originalFolderName);
	}

	@JSON
	public String getDescription() {
		if (_description == null) {
			return StringPool.BLANK;
		}
		else {
			return _description;
		}
	}

	public void setDescription(String description) {
		_description = description;
	}

	@JSON
	public Date getCreateDate() {
		return _createDate;
	}

	public void setCreateDate(Date createDate) {
		_createDate = createDate;
	}

	@JSON
	public Date getModifiedDate() {
		return _modifiedDate;
	}

	public void setModifiedDate(Date modifiedDate) {
		_modifiedDate = modifiedDate;
	}

	@JSON
	public long getFolderIdParent() {
		return _folderIdParent;
	}

	public void setFolderIdParent(long folderIdParent) {
		_columnBitmask |= FOLDERIDPARENT_COLUMN_BITMASK;

		if (!_setOriginalFolderIdParent) {
			_setOriginalFolderIdParent = true;

			_originalFolderIdParent = _folderIdParent;
		}

		_folderIdParent = folderIdParent;
	}

	public long getOriginalFolderIdParent() {
		return _originalFolderIdParent;
	}

	@JSON
	public long getUserId() {
		return _userId;
	}

	public void setUserId(long userId) {
		_columnBitmask |= USERID_COLUMN_BITMASK;

		if (!_setOriginalUserId) {
			_setOriginalUserId = true;

			_originalUserId = _userId;
		}

		_userId = userId;
	}

	public String getUserUuid() throws SystemException {
		return PortalUtil.getUserValue(getUserId(), "uuid", _userUuid);
	}

	public void setUserUuid(String userUuid) {
		_userUuid = userUuid;
	}

	public long getOriginalUserId() {
		return _originalUserId;
	}

	public long getColumnBitmask() {
		return _columnBitmask;
	}

	@Override
	public FolderEntry toEscapedModel() {
		if (_escapedModelProxy == null) {
			_escapedModelProxy = (FolderEntry)ProxyUtil.newProxyInstance(_classLoader,
					_escapedModelProxyInterfaces,
					new AutoEscapeBeanHandler(this));
		}

		return _escapedModelProxy;
	}

	@Override
	public ExpandoBridge getExpandoBridge() {
		if (_expandoBridge == null) {
			_expandoBridge = ExpandoBridgeFactoryUtil.getExpandoBridge(0,
					FolderEntry.class.getName(), getPrimaryKey());
		}

		return _expandoBridge;
	}

	@Override
	public void setExpandoBridgeAttributes(ServiceContext serviceContext) {
		getExpandoBridge().setAttributes(serviceContext);
	}

	@Override
	public Object clone() {
		FolderEntryImpl folderEntryImpl = new FolderEntryImpl();

		folderEntryImpl.setFolderId(getFolderId());
		folderEntryImpl.setFolderName(getFolderName());
		folderEntryImpl.setDescription(getDescription());
		folderEntryImpl.setCreateDate(getCreateDate());
		folderEntryImpl.setModifiedDate(getModifiedDate());
		folderEntryImpl.setFolderIdParent(getFolderIdParent());
		folderEntryImpl.setUserId(getUserId());

		folderEntryImpl.resetOriginalValues();

		return folderEntryImpl;
	}

	public int compareTo(FolderEntry folderEntry) {
		int value = 0;

		value = getFolderName().compareTo(folderEntry.getFolderName());

		if (value != 0) {
			return value;
		}

		return 0;
	}

	@Override
	public boolean equals(Object obj) {
		if (obj == null) {
			return false;
		}

		FolderEntry folderEntry = null;

		try {
			folderEntry = (FolderEntry)obj;
		}
		catch (ClassCastException cce) {
			return false;
		}

		long primaryKey = folderEntry.getPrimaryKey();

		if (getPrimaryKey() == primaryKey) {
			return true;
		}
		else {
			return false;
		}
	}

	@Override
	public int hashCode() {
		return (int)getPrimaryKey();
	}

	@Override
	public void resetOriginalValues() {
		FolderEntryModelImpl folderEntryModelImpl = this;

		folderEntryModelImpl._originalFolderName = folderEntryModelImpl._folderName;

		folderEntryModelImpl._originalFolderIdParent = folderEntryModelImpl._folderIdParent;

		folderEntryModelImpl._setOriginalFolderIdParent = false;

		folderEntryModelImpl._originalUserId = folderEntryModelImpl._userId;

		folderEntryModelImpl._setOriginalUserId = false;

		folderEntryModelImpl._columnBitmask = 0;
	}

	@Override
	public CacheModel<FolderEntry> toCacheModel() {
		FolderEntryCacheModel folderEntryCacheModel = new FolderEntryCacheModel();

		folderEntryCacheModel.folderId = getFolderId();

		folderEntryCacheModel.folderName = getFolderName();

		String folderName = folderEntryCacheModel.folderName;

		if ((folderName != null) && (folderName.length() == 0)) {
			folderEntryCacheModel.folderName = null;
		}

		folderEntryCacheModel.description = getDescription();

		String description = folderEntryCacheModel.description;

		if ((description != null) && (description.length() == 0)) {
			folderEntryCacheModel.description = null;
		}

		Date createDate = getCreateDate();

		if (createDate != null) {
			folderEntryCacheModel.createDate = createDate.getTime();
		}
		else {
			folderEntryCacheModel.createDate = Long.MIN_VALUE;
		}

		Date modifiedDate = getModifiedDate();

		if (modifiedDate != null) {
			folderEntryCacheModel.modifiedDate = modifiedDate.getTime();
		}
		else {
			folderEntryCacheModel.modifiedDate = Long.MIN_VALUE;
		}

		folderEntryCacheModel.folderIdParent = getFolderIdParent();

		folderEntryCacheModel.userId = getUserId();

		return folderEntryCacheModel;
	}

	@Override
	public String toString() {
		StringBundler sb = new StringBundler(15);

		sb.append("{folderId=");
		sb.append(getFolderId());
		sb.append(", folderName=");
		sb.append(getFolderName());
		sb.append(", description=");
		sb.append(getDescription());
		sb.append(", createDate=");
		sb.append(getCreateDate());
		sb.append(", modifiedDate=");
		sb.append(getModifiedDate());
		sb.append(", folderIdParent=");
		sb.append(getFolderIdParent());
		sb.append(", userId=");
		sb.append(getUserId());
		sb.append("}");

		return sb.toString();
	}

	public String toXmlString() {
		StringBundler sb = new StringBundler(25);

		sb.append("<model><model-name>");
		sb.append("vn.com.fis.portal.model.FolderEntry");
		sb.append("</model-name>");

		sb.append(
			"<column><column-name>folderId</column-name><column-value><![CDATA[");
		sb.append(getFolderId());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>folderName</column-name><column-value><![CDATA[");
		sb.append(getFolderName());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>description</column-name><column-value><![CDATA[");
		sb.append(getDescription());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>createDate</column-name><column-value><![CDATA[");
		sb.append(getCreateDate());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>modifiedDate</column-name><column-value><![CDATA[");
		sb.append(getModifiedDate());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>folderIdParent</column-name><column-value><![CDATA[");
		sb.append(getFolderIdParent());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>userId</column-name><column-value><![CDATA[");
		sb.append(getUserId());
		sb.append("]]></column-value></column>");

		sb.append("</model>");

		return sb.toString();
	}

	private static ClassLoader _classLoader = FolderEntry.class.getClassLoader();
	private static Class<?>[] _escapedModelProxyInterfaces = new Class[] {
			FolderEntry.class
		};
	private long _folderId;
	private String _folderName;
	private String _originalFolderName;
	private String _description;
	private Date _createDate;
	private Date _modifiedDate;
	private long _folderIdParent;
	private long _originalFolderIdParent;
	private boolean _setOriginalFolderIdParent;
	private long _userId;
	private String _userUuid;
	private long _originalUserId;
	private boolean _setOriginalUserId;
	private transient ExpandoBridge _expandoBridge;
	private long _columnBitmask;
	private FolderEntry _escapedModelProxy;
}